#ifndef     __REQUEST_H
#define     __REQUEST_H

#include "../serialize/decode.h"


namespace conn {

class RequestRef {

public:
    RequestRef(const uint8_t *buf, uint8_t len) : m_buf(buf), m_len(len) {}

    inline uint8_t type() const { return m_buf[0]; }
    inline uint8_t seq() const { return m_buf[1]; }

    inline uint8_t cmd() const { return m_buf[2]; }

    template <typename... Ts>
    utils::Error parse(Ts&... ts) const {
        return serialize::decode_all(m_buf + 3, m_len - 5, ts...);
    }

private:
    const uint8_t *m_buf;
    uint8_t m_len;
};

class Request : public RequestRef {

};

}



#endif
